//
//  BSNetWorkTool.swift
//  mySwiftWeibo
//
//  Created by apple on 16/7/19.
//  Copyright © 2016年 itcast沈庆伟. All rights reserved.
//

import UIKit

import AFNetworking

class BSNetWorkTool: AFHTTPSessionManager {

    
    // 网络请求前面一段不会变化
    // https://api.weibo.com/2/statuses/friends_timeline.json
    // https://api.weibo.com/2/statuses/mentions/ids.json
    // https://api.weibo.com/2/favorites.json
    // 单例
    
    // 遍历构造函数没办法在子类里面重写
    static let sharedNetworkTool: BSNetWorkTool = BSNetWorkTool(baseURL: NSURL(string: "https://api.weibo.com/"))
    

    
    // 自己来实现构造函数
    override init(baseURL url: NSURL?, sessionConfiguration configuration: NSURLSessionConfiguration?) {
        super.init(baseURL: url, sessionConfiguration: configuration)
        
        // 添加返回序列化器支持的类型
        self.responseSerializer.acceptableContentTypes?.insert("text/plain")
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
